package com.zr.eim.controller;

import java.util.List;
import javax.annotation.security.PermitAll;
import javax.servlet.http.HttpServletResponse;
import com.zr.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zr.common.annotation.Log;
import com.zr.common.core.controller.BaseController;
import com.zr.common.core.domain.AjaxResult;
import com.zr.common.enums.BusinessType;
import com.zr.eim.domain.EimDataDiagnosticInfo;
import com.zr.eim.service.IEimDataDiagnosticInfoService;
import com.zr.common.utils.poi.ExcelUtil;
import com.zr.common.core.page.TableDataInfo;

/**
 * 确诊信息Controller
 * 
 * @author peihang
 * @date 2022-10-21
 */
@RestController
@RequestMapping("/eim/diagnostic_info")
public class EimDataDiagnosticInfoController extends BaseController
{
    @Autowired
    private IEimDataDiagnosticInfoService eimDataDiagnosticInfoService;

    /**
     * 查询确诊信息列表
     */
    @PreAuthorize("@ss.hasPermi('eim:diagnostic_info:list')")
    @GetMapping("/list")
    public TableDataInfo list(EimDataDiagnosticInfo eimDataDiagnosticInfo)
    {
        startPage();
        List<EimDataDiagnosticInfo> list = eimDataDiagnosticInfoService.selectEimDataDiagnosticInfoList(eimDataDiagnosticInfo);
        return getDataTable(list);
    }

    /**
     * 导出确诊信息列表
     */
    @PreAuthorize("@ss.hasPermi('eim:diagnostic_info:export')")
    @Log(title = "确诊信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EimDataDiagnosticInfo eimDataDiagnosticInfo)
    {
        List<EimDataDiagnosticInfo> list = eimDataDiagnosticInfoService.selectEimDataDiagnosticInfoList(eimDataDiagnosticInfo);
        ExcelUtil<EimDataDiagnosticInfo> util = new ExcelUtil<EimDataDiagnosticInfo>(EimDataDiagnosticInfo.class);
        util.exportExcel(response, list, "确诊信息数据");
    }

    /**
     * 获取确诊信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('eim:diagnostic_info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(eimDataDiagnosticInfoService.selectEimDataDiagnosticInfoById(id));
    }

    /**
     * 新增确诊信息
     */
    @PreAuthorize("@ss.hasPermi('eim:diagnostic_info:add')")
    @Log(title = "确诊信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EimDataDiagnosticInfo eimDataDiagnosticInfo)
    {
        return toAjax(eimDataDiagnosticInfoService.insertEimDataDiagnosticInfo(eimDataDiagnosticInfo));
    }

    /**
     * 修改确诊信息
     */
    @PreAuthorize("@ss.hasPermi('eim:diagnostic_info:edit')")
    @Log(title = "确诊信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EimDataDiagnosticInfo eimDataDiagnosticInfo)
    {
        return toAjax(eimDataDiagnosticInfoService.updateEimDataDiagnosticInfo(eimDataDiagnosticInfo));
    }

    /**
     * 删除确诊信息
     */
    @PreAuthorize("@ss.hasPermi('eim:diagnostic_info:remove')")
    @Log(title = "确诊信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(eimDataDiagnosticInfoService.deleteEimDataDiagnosticInfoByIds(ids));
    }

    /**
     * 查询当前确诊人数
     * 需求模块：数据大屏
     */
    @Anonymous
    @PermitAll
    //@PreAuthorize("@ss.hasPermi('eim:diagnostic_info:query')")
    @PostMapping("/getCurrentNum")
    public AjaxResult getCurrentNum()
    {
        AjaxResult ajaxResult = AjaxResult.success(eimDataDiagnosticInfoService.getCurrentNum());
        return ajaxResult;
    }

    /**
     * 查询当前各区域确诊人数
     * 需求模块：数据大屏
     */
    @PreAuthorize("@ss.hasPermi('eim:diagnostic_info:query')")
    @Anonymous
    @PermitAll
    //@PreAuthorize("@ss.hasPermi('eim:diagnostic_info:query')")
    @PostMapping("/getAddressAndNum")
    public AjaxResult getAddressAndNum()
    {
        AjaxResult ajaxResult = AjaxResult.success(eimDataDiagnosticInfoService.getAddressAndNum());
        return ajaxResult;
    }

    /**
     * 查询当前确诊人数与日期
     * 需求模块：数据大屏
     */
    @PreAuthorize("@ss.hasPermi('eim:diagnostic_info:query')")
    @PostMapping("/getDiagnosticNumAndDate")
    public AjaxResult getDiagnosticNumAndDate()
    {
        AjaxResult ajaxResult = AjaxResult.success(eimDataDiagnosticInfoService.getDiagnosticNumAndDate());
        return ajaxResult;
    }
}
